{%- macro mailto_link(user) -%}
    <a href="mailto:{{ user.email }}">{{ user.email }}</a>
{%- endmacro -%}

{% macro quoted_post(
        post=None,
        recipient=None,
        quote_level=0,
        format=None,
        is_leaf_post=False
    )
%}
    {% spaceless %}
        {{ start_quote(quote_level) }}

            {% if recipient|can_see_private_user_data(post.author) %}
                {% set author = post.author.username|escape ~ '/(' ~ mailto_link(post.author) ~ ')' %}
            {% elif post.is_anonymous %}
                {% set author = post.author.get_name_of_anonymous_user()|escape %}
            {% else %}
                {% set author = post.author.username|escape %}
            {% endif %}

            {% if post.post_type == 'question' %}
                {% if quote_level > 0 %}
                <p style="font-size:10px; font-weight: bold;">
                {% else %}
                <p style="font-size:20px; font-weight: bold; margin: 10px 0">
                {% endif %}
                        {% if format == 'parent_subthread' %}
                            {% if is_leaf_post %}
                                {% trans %}Started by {{ author }}:{% endtrans %}
                            {% else %}
                                {% trans -%}
                                    In reply to {{ author }}:
                                {%- endtrans %}
                            {% endif %}
                        {% else %}
                            {{ settings.WORDS_QUESTION_SINGULAR|title|escape }} :
                        {% endif %}
                        {{ post.thread.title }}
                </p>
                {% if quote_level > 0 %}
                <p style="font-size:10px; font-weight: bold;">
                        {% if format != 'parent_subthread' %}
                            {% trans %}Started by {{ author }}:{% endtrans %}
                        {% endif %}
                </p>
                {% endif %}
                {% set tag_names = post.get_tag_names() %}
                {% if tag_names %}
                <p style="font-size:10px; font-style:italic;">
                    {% trans %}Tags:{% endtrans %}
                    {{ tag_names|join(', ') }}.
                </p>
                {% endif %}
            {% elif post.post_type == 'answer' %}
                <p style="font-size:10px; font-weight: bold;">
                    {% if format == 'parent_subthread' %}
                        {% if is_leaf_post %}
                            {% trans -%}
                                {{ author }}'s response:
                            {%- endtrans %}
                        {% else %}
                            {% trans -%}
                                In reply to {{ author }}:
                            {%- endtrans %}
                        {% endif %}
                    {% else %}
                        {% trans %}Replied by {{ author }}:{% endtrans %}
                    {% endif %}
                </p>
            {% else %}
                <p style="font-size:10px; font-weight: bold;">
                    {% if format == 'parent_subthread' %}
                        {% if is_leaf_post %}
                            {% trans -%}
                                {{ author }}'s comment:
                            {%- endtrans %}
                        {% else %}
                            {% trans -%}
                                In reply to {{ author }}'s comment:
                            {%- endtrans %}
                        {% endif %}
                    {% else %}
                        {% trans author -%}
                            Commented by {{ author }}:
                        {%- endtrans %}
                    {% endif %}
                </p>
            {% endif %}
            {{ post.html }}
        {{ end_quote(quote_level) }}
    {% endspaceless %}
{% endmacro %}

{% macro start_quote(level = 0) %}
    {% for number in range(level) %}
        <div style="padding-left:5px; border-left: 2px solid #aaa;">
    {% endfor %}
{% endmacro %}

{% macro end_quote(level = 0) %}
    {% for number in range(level) %}
        </div>
    {% endfor %}
{% endmacro %}

{% macro heading_style() %}
font-size:14px;font-weight:bold;margin-bottom:0px;
{% endmacro %}

{% macro fine_print_style() %}
font-size:8px;color:#aaa;margin-bottom:0px;
{% endmacro %}
